package n1338;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	
	static int p[]= {0,0,0};
	
	static int v[]= {2,3,5};
	
	static int a[]=new int[1500];
	
	static void init()
	{
		a[0]=1;
		for(int i=1;i<1500;i++)
		{
			int min=a[p[0]]*v[0];
			for(int j=1;j<p.length;j++)
			{
				if(min>a[p[j]]*v[j])min=a[p[j]]*v[j];
			}
			for(int j=0;j<p.length;j++)
			{
				if(min==a[p[j]]*v[j])p[j]=p[j]+1;
			}
			a[i]=min;
		}
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		init();
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line=null;
		while((line=bf.readLine())!=null)
		{
			int n=Integer.parseInt(line);
			if(n==0)break;
			System.out.println(a[n-1]);
		}
	}

}
